package com.ly.ymall.manager.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.ly.ymall.pojo.BaseCatalog1;
import com.ly.ymall.pojo.BaseCatalog2;
import com.ly.ymall.pojo.BaseCatalog3;
import com.ly.ymall.service.CatalogService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: LIMING
 * @Date: 2019/2/27 18:21
 * @Description:
 */
@RestController
public class CatalogController {

    @Reference
    CatalogService catalogService;


    @GetMapping("catalog1List")
    public String getCatalog1List(){
        List<BaseCatalog1> catalog1List = catalogService.getCatalog1List();
        return JSON.toJSONString(catalog1List);
    }

    @RequestMapping("catalog2List")
    public String getCatalog2List(@RequestParam Integer catalog1Id){
        List<BaseCatalog2> catalog2List = catalogService.getCatalog2List(catalog1Id);
        return JSON.toJSONString(catalog2List);
    }

    @RequestMapping("catalog3List")
    public String getCatalog3List(@RequestParam Integer catalog2Id){
        List<BaseCatalog3> catalog3List = catalogService.getCatalog3List(catalog2Id);
        return JSON.toJSONString(catalog3List);
    }

}
